import { defineStore } from "pinia";


// 真正存储数据的地方
export const useTabsStore = defineStore("tabs", {
    state: () => ({
        editableTabsValue: '/admin/workSpace/console',
        editableTabs: [
            {
                title: '控制台',
                name: '/admin/workSpace/console'
            }
        ],
    }),

    actions: {
        // setToken(token) {
        //     this.token = token;
        // },
        // setCurrentUser(currentUser) {
        //     this.currentUser = currentUser;
        // },

        ADD_TABS(tab: any) {
            if (this.editableTabs.findIndex(e => e.name === tab.path) === -1) {
                this.editableTabs.push({
                    title: tab.name,
                    name: tab.path
                })
            }
            this.editableTabsValue = tab.path
        },
        RESET_TAB() {
            this.editableTabsValue = '/index'
            this.editableTabs = [
                {
                    title: '控制台',
                    name: '/admin/workSpace/console'
                }
            ]
        }
    },
});

export default useTabsStore;